package cn.ctodb.cms.service.mapper;

import cn.ctodb.cms.domain.*;
import cn.ctodb.cms.service.dto.CmsFileDTO;

import org.mapstruct.*;
import java.util.List;

/**
 * Mapper for the entity CmsFile and its DTO CmsFileDTO.
 */
@Mapper(componentModel = "spring", uses = {})
public interface CmsFileMapper {

    @Mapping(source = "cmsContent.id", target = "cmsContentId")
    CmsFileDTO cmsFileToCmsFileDTO(CmsFile cmsFile);

    List<CmsFileDTO> cmsFilesToCmsFileDTOs(List<CmsFile> cmsFiles);

    @Mapping(source = "cmsContentId", target = "cmsContent")
    CmsFile cmsFileDTOToCmsFile(CmsFileDTO cmsFileDTO);

    List<CmsFile> cmsFileDTOsToCmsFiles(List<CmsFileDTO> cmsFileDTOs);

    default CmsContent cmsContentFromId(Long id) {
        if (id == null) {
            return null;
        }
        CmsContent cmsContent = new CmsContent();
        cmsContent.setId(id);
        return cmsContent;
    }
}
